package com.api.oa.mapper;

import com.api.oa.model.entity.${entityName};
import com.api.oa.model.vo.OaNoticeVo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface ${entityName}Mapper {

    @Insert("insert into  ${tableName}  (" +
    <#list fields as field>
        "${field}," +
    </#list>
    ") " +
    "values " +
    "(" +
    <#list fields as field>
        "# {entity.${field}}," +
    </#list>
    ")" )
    @Options(useGeneratedKeys = true, keyProperty = "noticeId", keyColumn = "id")
    Integer insert(@Param("entity") ${entityName} entity);



    @Update("update  ${tableName}  set " +
    <#list fields as field>
        "${field} = # {entity.${field}}," +
    </#list>
    " where messageId = # {entity.classifyId}")
    Integer update(@Param("entity") ${entityName}  entity);


    @Delete("delete from ${tableName} where noticeId=# {id}")
    void delete(@Param("id") Long id);


    @Select("select * from  ${tableName} ")
    List<${entityName}> list(@Param("id") Long pid);


    @Select("select * from  ${tableName}  where noticeId = # {id} limit 1")
    ${entityName} findOne(@Param("id") Long id);

}

